<template>
  <div class="container">
    <list-table-new v-bind="tableSetting" ref="listTable"></list-table-new>
  </div>
</template>

<script>
import {
  getListApi
} from "@/api/orderManagement/defectOrder"
export default {
  data(){
    return {
      tableSetting: {
        radioShow: true,
        showCustomBtn: false, //隐藏自定义列按钮
        showFilterBtn: false, //隐藏过滤器按钮
        searchObj: {
          searchMethod: (params, sortStr) => {
            this.getTableData(params);
          },
          queryData: {
            page: 1,
            pageSize: 15,
          },
          searchArr: [
            {
              type: "input",
              label: "编号",
              model: "code"
            },
            {
              type: "input",
              label: "标题",
              model: "title"
            },
            {
              type: "select",
              label: "状态",
              model: "status",
              option: [
                {
                  label: "待执行",
                  value: "WAIT_EXECUTE"
                },
                {
                  label: "执行中",
                  value: "IN_EXECUTE"
                },
                {
                  label: "待派工",
                  value: "WAIT_DISPATCH"
                },
              ]
            },
            // {
            //   type: "dept",
            //   label: "设备单位",
            //   model: "deptManageName",
            //   idsStr: "deptManage"
            // },
          ]
        },
        column: [
          {
            label: "状态",
            prop: "status",
            formatter: row => {
              return this.$store.getters["fineDirtDataName"](
                "order_all_status",
                row.status
              );
            }
          },
          {
            label: "编号",
            prop: "code"
          },
          {
            label: "标题",
            prop: "title"
          },
          {
            label: "设备管理单位",
            prop: "deptManageName"
          },
          {
            label: "设备",
            prop: "equipmentName"
          },
          {
            label: "缺陷关键字",
            prop: "keys"
          },
          {
            label: "当前节点",
            prop: "currNodeName"
          },
          {
            label: "当前处理人",
            prop: "currNodeUser"
          },
          {
            label: "发现人",
            prop: "finderName"
          },
          {
            label: "创建时间",
            prop: "createTime"
          },
        ],
        //表格方法
        tableMethods: {
          //点击行的方法
          rowClick: row => {
            this.$refs.listTable.radioSelect(row);
          }
        }
      }
    }
  },
  methods: {
    getTableData(params, sortStr) {
      let form = { ...params };
      form.statusList = [
        "WAIT_EXECUTE",
        "IN_EXECUTE",
        "WAIT_DISPATCH"
      ];
      getListApi(form)
        .then(res => {
          let data = res.data.list || [];
          let total = res.data.total || 0;
          this.$set(this.tableSetting, "tableData", data);
          this.$set(this.tableSetting, "totalNumber", total);
        })
        .catch(e => {
          this.$set(this.tableSetting, "tableData", []);
          this.$set(this.tableSetting, "totalNumber", 0);
        });
    },
    //获取选择结果
    getSelectData() {
      let data = this.$refs.listTable.getRadioData();
      return data;
    }
  },
  created(){
    this.getTableData();
  }
}
</script>
<style lang="less" scoped>

.container {
  width: 100%;
  height: 100%;
  background-color: white;
  display: flex;
  .class-tree {
    height: 100%;
    width: 300px;
    border-top: 10px solid #f2f3f8;
  }
  .detail-content {
    height: 100%;
    width: calc(100% - 300px);
    border-left: 10px solid #f2f3f8;
    border-top: 10px solid #f2f3f8;
    padding: 20px;
    flex: 1;
  }
}
</style>